package Presenter;

import java.util.List;
import java.util.Random;

import Model.I_Interactable.Actions;

import Model.NPC.NPCType;
import Model.SpaceTravelModel;

public class SpaceTravelPresenter{
	/**
	 * 
	 */
	private final SpaceTravelModel model;

	/**
	 * 
	 */
	private final Random rand;

	/**
	 * 
	 */
	private String promptText;

	/**
	 * 
	 */
	private int numberOfTransitions;

	/**
	 * 
	 */
	private int numberOfInteractions;
	
	public SpaceTravelPresenter(){
		rand = new Random();
		model = new SpaceTravelModel();
		numberOfTransitions = 0;
		generateNumberOfInteractions();
	}
	
	public boolean canTransition(){
		return numberOfTransitions != numberOfInteractions;
	}
	
	public int getNumberOfTransitions() {
		return numberOfTransitions;
	}

	public void setNumberOfTransitions(int numberOfTransitions) {
		this.numberOfTransitions = numberOfTransitions;
	}

	public String getPromptText() {
		return promptText;
	}

	public void setPromptText(String promptText) {
		this.promptText = promptText;
	}

	public String getPrompt(NPCType type){
		if(type == NPCType.PIRATE){
			return "You have encountered a Pirate! What will you do?!!!";
		}
		if(type == NPCType.POLICE){
			return "You have encountered a Police! What will you do?!!!";
		}
		if(type == NPCType.TRADER){
			return "You have encountered a Trader!";
		}
		
		return "";
	}
	
	public void generateNumberOfInteractions(){
		this.numberOfInteractions = rand.nextInt(4) + 1;
	}
	
	public int getNumberofInteractions(){
		
		return numberOfInteractions;
		
	}
	
	public List<Actions> getAction(NPCType type){
		if(type == NPCType.PIRATE){
			return model.getPirateAction();
		}
		else if(type == NPCType.POLICE){
			return model.getPoliceAction();
		}
		else{
			return model.getTraderAction();
		}
	}
	
	public NPCType getInteraction(){
		final double num = rand.nextDouble();
		if(num <= .45){
			return NPCType.PIRATE;
		}
		else{
			return NPCType.POLICE;
		}
	}
	
	public String toString(){
		return super.toString();
	}
}
